<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>模板字符串</title>
</head>
<body>
  <div class="box">
    <!-- <ul>
      <li>
        <p id="1">chengjunyu</p>
      </li>
    </ul> -->
  </div>
</body>

<script type="text/javascript">
  const oBox = document.querySelector('.box')
  console.log(oBox)
  // 原始方式
  let id = 1,
      name = 'chengjunyu1'
  oBox.innerHTML = "<ul><li><p id="+ id + ">" + name + "</p></li></ul>"

  // es6模板字符串，使用tab键上面的~
  let id2 = 2, name2 = 'chengjunyu2'
  let htmlStr = `<ul>
                  <li>
                    <p id=${id2}>${name2}</p>
                  </li>
                 </ul>`
  oBox.innerHTML = htmlStr

</script>
</html>